package com.teamwhole.modules.gcb.web;

import java.util.List;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.teamwhole.common.model.ResultInfo;
import com.teamwhole.modules.gcb.entity.Square;
import com.teamwhole.modules.gcb.service.SquareService;

@Component
@Path("/gcb/square")
@Consumes("application/json;charset=utf-8")
@Produces("application/json;charset=utf-8")
public class SquareResource {
	
	@Autowired
	private SquareService squareService;
	
	//在列表中显示所有数据
	@Path("/findList")
	@POST
	public List<Square> findByLoginName() {
		return squareService.findList(new Square());
	}
	
	//返回一个
	@Path("/get")
	@GET
	public Square get(@QueryParam("id") String id) {
		return squareService.get(id);
	}
	
	//增加一个 
	@Path("/create")
	@POST
	public ResultInfo create(Square model) {
		squareService.save(model);
		return ResultInfo.ok();
	}
	
	//更新
	@Path("/update")
	@POST
	public ResultInfo update(Square model) {
		squareService.save(model);
		return ResultInfo.ok();
	}
	
	//删除
	@Path("/delete")
	@GET
	public ResultInfo delete(@QueryParam("id") String id) {
		squareService.delete(id);
		return ResultInfo.ok();
	}
}
